<?php 
/* 
Template Name: quan li may tv
*/
?>
<?php get_header(); ?>
<?php 
 
if ( ! current_user_can( 'list_users' ) ) 
    {
      wp_die( __( 'bạn không có quyền truy cập trang này! ' ) );

            global $id_sai_email;$status_pass;
            global $current_user;
            get_currentuserinfo();
    }//if ( ! current_user_can( 'list_users' ) ) 
    else { ?>
     

<div id="content_nano_two" class="clearfix">
    <?php // get_template_part('includes/breadcrumbs'); ?>
    <?php // $product_count = $wpdb->get_var( "SELECT COUNT(*) FROM wp_may" ); echo "<p>Số lượng máy {$product_count}</p>";
    ?>
    <?php //get_template_part('includes/top_info'); ?>
     
<a  href='<?php bloginfo('url');?>/them-may'> 
  <button  class="button action" id='them_moi_nhieu'> Thêm máy </button></a>
   
      
<?php 

     
                        $query_user = "SELECT * FROM wp_may" ;
                       
    ?>            



              
                      <form  >
                        
                        

                      

                                      <table class="wp-list-table widefat fixed users" cellspacing="0">
                                        <thead>
                                          <tr>
                                            <th scope="col" id="cb" class="manage-column column-cb check-column" style=""> </th>
                                            <th scope="col" id="username"  style="text-align: center;">
                                                <span>Ảnh</span>
                                            </th>
                                            <th scope="col" id="name"  style="text-align: center;">
                                            <span>Tên máy</span>
                                            </th>
                                            <th scope="col" id="email" style="text-align: center;position: relative;float: right;text-align: center;">
                                                  <span style='margin: 0px 0px 0px 143px;'>Xử lí</span>
                                            </th>
                                            <th scope="col" style="text-align: center;">
                                              <span></span>
                                          </th>
                                            <th scope="col" id="role" style="text-align: center;">Phân quyền</th>
                                          </tr>
                                        </thead>

                                        <tfoot>
                                        <tr>
                                          <th scope="col" style=""> </th>
                                          <th scope="col"  style="text-align: center;">
                                              <span>Ảnh</span>
                                          </th>
                                          <th scope="col" style="text-align: center;">
                                              <span >Tên máy</span>
                                          </th>
                                          <th scope="col" style="text-align: center;text-align: center;position: relative;right: -28px;float: right;top: 1px;">
                                              <span>Xử lí</span>
                                          </th>
                                          <th scope="col" style="text-align: center;">
                                              <span></span>
                                          </th>
                                          <th scope="col"  style="text-align: center;">Phân quyền</th>
                                        </tr>
                                        </tfoot>

                                        <tbody id="the-list" data-wp-lists="list:user">

                                      <?php 
                                         $rows = $wpdb->get_results($query_user);
                                        foreach($rows as $post)
                                          //var_dump($post);
                                        {

                                      ?>
                                        <tr id="product-<?php $post->id_may; ?>" class="alternate">

                                          <th scope="row" class="check-column"> </th>

                                          <td >

                                          <img alt="<?php echo $post->name_may;?>" src="<?php echo get_bloginfo('template_directory').'/upload_may/'.$post->image_may_url;?>" class="avatar avatar-32 photo" height="40" width="40" style="padding-left: 90px;"> 
                                          </td>
                                        

                                               
                                              <td class="name column-name" style="text-align: center;font-weight: bold;"><?php echo $post->name_may;?></td>
                                            <td class="email column-email" style="padding-left: 127px;">
                                                   <form action='<?php bloginfo('url');?>/edit-product' method='POST'>
                                                      <fieldset>
                                                        <input type="hidden" name="edit_prod" id="edit_prod" value='<?php echo $post->id_may; ?>'>
                                                        <input type="submit" name="edit_<?php echo $post->id_may;?>" id="edit_<?php echo $post->id_may;?>" value='Sửa'/>
                                                      </fieldset>
                                                  </form>
                                            </td>

                                            <td> <a href="javascript:confirmDelete('<?php bloginfo('url');?>/delete_product/<?php echo $post->id_may; ?>')">
                                              <p>xóa</p>
                                             </a>

                                             <script>
                                                function confirmDelete(delUrl)
                                                {
                                                if (confirm("Bạn có chắc muốn xóa sản phẩm này không?"))
                                                {
                                                  document.location = delUrl;
                                                }
                                                }
                                            </script> </td>

                                            <td > 
                                              <form action='<?php bloginfo('url');?>/delete-product' method='POST'>
                                                      <fieldset>
                                                        <input type="hidden" name="del_prod" id="del_prod" value='<?php echo $post->id_may; ?>' />
                                                        <input type="submit" name="del_<?php echo $post->id_may;?>" id="del_<?php echo $post->id_may;?>" value='Xóa'/>
                                                      </fieldset>
                                                  </form>
                                            </td>
                                            <td class="role column-role" style='padding: 3px 3px 3px 45px;'>
                                              <form action='<?php bloginfo('url');?>/manager-product-set' method='POST'>
                                              
                                          <input type='hidden' name='id_may' id='id_may' value='<?php echo $post->id_may;?>'/>
                                          <input  class="edit" type='submit' name='edit_may' value='Tạo phân quyền'/>
                                              
                                            </form>
                                            </td>
                                           
                                       </tr><!-- id="user-xyz" class="alternate" -->

                                      <?php } // end foreach($rows as $post) ?>


                                       </tbody>
                                      </table>

                       
                        
             </form>
          



</div><!-- id="content_nano_two" -->

<?php } //elseif ( ! current_user_can( 'list_users' ) )  ?>
    
<?php get_footer(); ?>